home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 026a / strdct.zip / STRDCTID.C < prev   
C/C++ Source or Header  |  1991-01-24  |  7KB  |  141 lines

  1. /*  Program ...:  Strdct.C
  2.     Author ....:  Erik A McBeth
  3.     Date ......:  February 1, 1990
  4.     Version ...:  dBASE IV 1.0, 1.1
  5.                   (Tested compilers/assemblers)
  6.                   Turbo C 1.5, 2.0  TASM 1.0
  7.                   Microsoft C 5.1   MASM 5.1
  8.  
  9.     C program which can be used to sort data in dictionary order
  10.     in which you have symbols first, then letters, then numbers.
  11.  
  12.     To create bin file:
  13.         Compile Strdct.C to Strdct.OBJ
  14.         LINK Strdct+Getregs,Strdct,,,  See Strlib.h
  15.         EXE2BIN Strdct
  16.  
  17.     The Strdct.BIN file can then be called from inside dBASE
  18.         LOAD Strdct
  19.     CALL Strdct WITH string
  20.         in dBASE IV you can also do
  21.        ? CALL("Strdct",string)
  22.     in dBASE IV you can also use this in indexing
  23.        INDEX ON CALL("Strdct",string+"") TO index
  24.     place the "" in there so the field is not permanently
  25.     changed.
  26.  
  27. */
  28.  
  29. #include "strdct.h"
  30.  
  31. void far main() /* very important, make sure we get a far return */
  32. {
  33.  
  34. /*   Tried to make this look familiar to 'C' programmers, notice the
  35.      use of argc and argv, I've set argc to have a value of 2 to
  36.      simulate the routine being call from the DOS prompt */
  37.  
  38.       int  argc;
  39.       unsigned char far *argv[6];
  40.  
  41.       Getregs(); /* Assign memory registers */
  42.  
  43. /*    Translate the parameter passed by dBASE IV into something we
  44.       can use, the argv[2] and argv[3] are placed here to show
  45.       you how to read multiple parameters */
  46.  
  47.      argc    = CX+1; /* Number of arguments */
  48.      argv[1] = (unsigned char far *)*((unsigned long *)MK_LONG(ES, DI +  0));
  49.      argv[2] = (unsigned char far *)*((unsigned long *)MK_LONG(ES, DI +  4));
  50.      argv[3] = (unsigned char far *)*((unsigned long *)MK_LONG(ES, DI +  8));
  51.  
  52.      if (argc>1)  /* Do we have a string to use? */
  53.        Strdct(argv[1]);
  54.  
  55. }
  56.  
  57. Strdct(str)
  58. unsigned char far *str;
  59. {
  60.  
  61. /*     Had to do it this way, couldn't do "trnslt[]={"  */
  62.  
  63.     /* Read from ameng.SO (Framework III)
  64.        Table is case insensitive 
  65.        Table is in descending order */
  66.     static unsigned char trnslt[256];
  67.  
  68.     trnslt[  0]=255; trnslt[  1]=254; trnslt[  2]=253; trnslt[  3]=252; 
  69.     trnslt[  4]=251; trnslt[  5]=250; trnslt[  6]=249; trnslt[  7]=248; 
  70.     trnslt[  8]=247; trnslt[  9]=246; trnslt[ 10]=245; trnslt[ 11]=244; 
  71.     trnslt[ 12]=243; trnslt[ 13]=242; trnslt[ 14]=241; trnslt[ 15]=240; 
  72.     trnslt[ 16]=239; trnslt[ 17]=238; trnslt[ 18]=237; trnslt[ 19]=236; 
  73.     trnslt[ 20]=235; trnslt[ 21]=234; trnslt[ 22]=233; trnslt[ 23]=232; 
  74.     trnslt[ 24]=231; trnslt[ 25]=230; trnslt[ 26]=229; trnslt[ 27]=228; 
  75.     trnslt[ 28]=227; trnslt[ 29]=226; trnslt[ 30]=225; trnslt[ 31]=224; 
  76.     trnslt[' ']=223; trnslt['!']=222; trnslt['\"']=221; trnslt['#']=220; 
  77.     trnslt['$']=219; trnslt['%']=218; trnslt['&']=217; trnslt['\'']=216; 
  78.     trnslt['(']=215; trnslt[')']=214; trnslt['*']=213; trnslt['+']=212; 
  79.     trnslt[',']=211; trnslt['-']=210; trnslt['.']=209; trnslt['/']=208; 
  80.     trnslt['0']=148; trnslt['1']=147; trnslt['2']=146; trnslt['3']=145; 
  81.     trnslt['4']=144; trnslt['5']=143; trnslt['6']=142; trnslt['7']=141; 
  82.     trnslt['8']=140; trnslt['9']=139; trnslt[':']=207; trnslt[';']=206; 
  83.     trnslt['<']=205; trnslt['=']=204; trnslt['>']=203; trnslt['?']=202; 
  84.     trnslt['@']=201; trnslt['A']=200; trnslt['B']=193; trnslt['C']=192; 
  85.     trnslt['D']=190; trnslt['E']=189; trnslt['F']=184; trnslt['G']=183; 
  86.     trnslt['H']=182; trnslt['I']=181; trnslt['J']=176; trnslt['K']=175; 
  87.     trnslt['L']=174; trnslt['M']=173; trnslt['N']=172; trnslt['O']=170; 
  88.     trnslt['P']=164; trnslt['Q']=163; trnslt['R']=162; trnslt['S']=161; 
  89.     trnslt['T']=160; trnslt['U']=159; trnslt['V']=154; trnslt['W']=153; 
  90.     trnslt['X']=152; trnslt['Y']=151; trnslt['Z']=149; trnslt['[']=138; 
  91.     trnslt['\\']=136; trnslt[']']=135; trnslt['^']=134; trnslt['_']=133; 
  92.     trnslt['`']=132; trnslt['a']=200; trnslt['b']=193; trnslt['c']=192; 
  93.     trnslt['d']=190; trnslt['e']=189; trnslt['f']=184; trnslt['g']=183; 
  94.     trnslt['h']=182; trnslt['i']=181; trnslt['j']=176; trnslt['k']=175; 
  95.     trnslt['l']=174; trnslt['m']=173; trnslt['n']=172; trnslt['o']=170; 
  96.     trnslt['p']=164; trnslt['q']=163; trnslt['r']=162; trnslt['s']=161; 
  97.     trnslt['t']=160; trnslt['u']=159; trnslt['v']=154; trnslt['w']=153; 
  98.     trnslt['x']=152; trnslt['y']=151; trnslt['z']=149; trnslt['{']=131; 
  99.     trnslt['|']=130; trnslt['}']=129; trnslt['~']=128; trnslt[127]=127; 
  100.     trnslt[128]=191; trnslt[129]=158; trnslt[130]=188; trnslt[131]=197; 
  101.     trnslt[132]=199; trnslt[133]=196; trnslt[134]=198; trnslt[135]=191; 
  102.     trnslt[136]=187; trnslt[137]=186; trnslt[138]=185; trnslt[139]=180; 
  103.     trnslt[140]=179; trnslt[141]=178; trnslt[142]=199; trnslt[143]=198; 
  104.     trnslt[144]=188; trnslt[145]=255; trnslt[146]=255; trnslt[147]=168; 
  105.     trnslt[148]=169; trnslt[149]=167; trnslt[150]=157; trnslt[151]=156; 
  106.     trnslt[152]=150; trnslt[153]=169; trnslt[154]=158; trnslt[155]='~'; 
  107.     trnslt[156]='}'; trnslt[157]='|'; trnslt[158]='{'; trnslt[159]='z'; 
  108.     trnslt[160]=195; trnslt[161]=177; trnslt[162]=166; trnslt[163]=155; 
  109.     trnslt[164]=171; trnslt[165]=171; trnslt[166]=194; trnslt[167]=165; 
  110.     trnslt[168]='y'; trnslt[169]='x'; trnslt[170]='w'; trnslt[171]='v'; 
  111.     trnslt[172]='u'; trnslt[173]='t'; trnslt[174]='s'; trnslt[175]='r'; 
  112.     trnslt[176]='q'; trnslt[177]='p'; trnslt[178]='o'; trnslt[179]='n'; 
  113.     trnslt[180]='m'; trnslt[181]='l'; trnslt[182]='k'; trnslt[183]='j'; 
  114.     trnslt[184]='i'; trnslt[185]='h'; trnslt[186]='g'; trnslt[187]='f'; 
  115.     trnslt[188]='e'; trnslt[189]='d'; trnslt[190]='c'; trnslt[191]='b'; 
  116.     trnslt[192]='a'; trnslt[193]='`'; trnslt[194]='_'; trnslt[195]='^'; 
  117.     trnslt[196]=']'; trnslt[197]='\\'; trnslt[198]='['; trnslt[199]='Z'; 
  118.     trnslt[200]='Y'; trnslt[201]='X'; trnslt[202]='W'; trnslt[203]='V'; 
  119.     trnslt[204]='U'; trnslt[205]='T'; trnslt[206]='S'; trnslt[207]='R'; 
  120.     trnslt[208]='Q'; trnslt[209]='P'; trnslt[210]='O'; trnslt[211]='N'; 
  121.     trnslt[212]='M'; trnslt[213]='L'; trnslt[214]='K'; trnslt[215]='J'; 
  122.     trnslt[216]='I'; trnslt[217]='H'; trnslt[218]='G'; trnslt[219]='F'; 
  123.     trnslt[220]='E'; trnslt[221]='D'; trnslt[222]='C'; trnslt[223]='B'; 
  124.     trnslt[224]='A'; trnslt[225]=255; trnslt[226]='?'; trnslt[227]='>'; 
  125.     trnslt[228]='='; trnslt[229]='<'; trnslt[230]=';'; trnslt[231]=':'; 
  126.     trnslt[232]='9'; trnslt[233]='8'; trnslt[234]='7'; trnslt[235]='6'; 
  127.     trnslt[236]='5'; trnslt[237]='4'; trnslt[238]='3'; trnslt[239]='2'; 
  128.     trnslt[240]='1'; trnslt[241]='0'; trnslt[242]='/'; trnslt[243]='.'; 
  129.     trnslt[244]='-'; trnslt[245]=','; trnslt[246]='+'; trnslt[247]='*'; 
  130.     trnslt[248]=')'; trnslt[249]='('; trnslt[250]='\''; trnslt[251]='&'; 
  131.     trnslt[252]='%'; trnslt[253]='$'; trnslt[254]='\"'; trnslt[255]='!'; 
  132.  
  133. /*  Go through the string and substitute the new value based on the
  134.     value of the old character */
  135.  
  136.     for(;*str;str++) {
  137.          *str = trnslt[(int)*str];
  138.       }
  139.  
  140. }
  141.